Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(layertreeview): add checks on selectedModel to avoid segfault #59337

Merged

Conversation

Djedouas
Copy link
Member

@Djedouas Djedouas commented Nov 5, 2024

Description

Fixes #59329

QGIS crashes when executing this line (and other from the same family) in the Python console:

QgsLayerTreeView().selectedLayers()

Copy link

github-actions bot commented Nov 5, 2024

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 6961b8c)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 6961b8c)

@rouault
Copy link
Contributor

rouault commented Nov 5, 2024

@Djedouas
Copy link
Member Author

Djedouas commented Nov 6, 2024

@nyalldawson @rouault do you have an idea why the Qt6 test has a segfault? I can run the test in both Qt5 and Qt6 on my machine and it is fine...

Is seems as if the Qt6 test uses the code without my modifications...

@rouault
Copy link
Contributor

rouault commented Nov 6, 2024

I can run the test in both Qt5 and Qt6 on my machine and it is fine...

did you try running under Valgrind, just in case this might be something subtle... Or maybe it is due to a difference of Qt6 versions between your machine and the CI one ?

@nyalldawson
Copy link
Collaborator

@Djedouas looks like the test is actually hanging and timing out and being forcefully closed. But I can't see anything here that would lead to a hang... 🤔

I'd check if it's the new test causing this (as opposed to an existing test impacted by these changes) by temporarily removing it...

Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 23, 2024
@Djedouas Djedouas removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 25, 2024
@Djedouas Djedouas force-pushed the fix-segfault-layertreeview-without-model branch 4 times, most recently from 8aecbdd to c2d81ec Compare November 26, 2024 14:04
check calls to layerTreeModel(), selectedModel(), and use of mProxyModel
@Djedouas Djedouas force-pushed the fix-segfault-layertreeview-without-model branch from c2d81ec to 6961b8c Compare November 26, 2024 16:08
@Djedouas
Copy link
Member Author

@nyalldawson @rouault Fixed the test by adding more checks on potentially nullptr:

  • layerTreeModel()
  • selectedModel()
  • mProxyModel

@nyalldawson nyalldawson merged commit acc0089 into qgis:master Nov 26, 2024
30 checks passed
@qgis-bot
Copy link
Collaborator

The backport to queued_ltr_backports failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 6961b8cbc61... fix(layertreeview): add checks on nullptr to avoid segfaults
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging src/gui/layertree/qgslayertreeview.cpp
CONFLICT (content): Merge conflict in src/gui/layertree/qgslayertreeview.cpp
Auto-merging tests/src/python/test_qgslayertreeview.py

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-queued_ltr_backports queued_ltr_backports
# Navigate to the new working tree
cd .worktrees/backport-queued_ltr_backports
# Create a new branch
git switch --create backport-59337-to-queued_ltr_backports
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 6961b8cbc61bd59e27f09bd8c8fb57eefb9cad9d
# Push it to GitHub
git push --set-upstream origin backport-59337-to-queued_ltr_backports
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-queued_ltr_backports

Then, create a pull request where the base branch is queued_ltr_backports and the compare/head branch is backport-59337-to-queued_ltr_backports.

@qgis-bot qgis-bot added the failed backport The automated backport attempt failed, needs a manual backport label Nov 26, 2024
@qgis-bot
Copy link
Collaborator

The backport to release-3_34 failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply 6961b8cbc61... fix(layertreeview): add checks on nullptr to avoid segfaults
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging src/gui/layertree/qgslayertreeview.cpp
CONFLICT (content): Merge conflict in src/gui/layertree/qgslayertreeview.cpp
Auto-merging tests/src/python/test_qgslayertreeview.py

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release-3_34 release-3_34
# Navigate to the new working tree
cd .worktrees/backport-release-3_34
# Create a new branch
git switch --create backport-59337-to-release-3_34
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick 6961b8cbc61bd59e27f09bd8c8fb57eefb9cad9d
# Push it to GitHub
git push --set-upstream origin backport-59337-to-release-3_34
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release-3_34

Then, create a pull request where the base branch is release-3_34 and the compare/head branch is backport-59337-to-release-3_34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports backport release-3_40 failed backport The automated backport attempt failed, needs a manual backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash after enter a python line
4 participants